\\  \r c:\pari\partition.gp via Richard Mathar 
\\ ref http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=671
partit(n)={
	local(resul,partm,filr) ;
	if( type(n) != "t_INT",
		error("Argument ", n, " to partit() is not an integer!")
	) ;
	if( n < 0,
		return([;]) ;
	) ;
	resul=matrix(0,n) ;
	/* For each number of terms from 1 to n, we create the partitions
	* with that number of terms, fill the corresponding matrices with
	* zeros to the right and add them to the bottom of the existing
	* intermediate set of results.
	*/
	for(m=1,n,
		partm=partitm(n,m,1) ;
		filr=vector(n-m) ;
		for(r1=1,matsize(partm)[1],
			resul=concat( resul,concat(partm[r1,],filr) ) ;
		) ;
	) ;
	return(resul) ;
}
partitm(n,m,nmin)={
	local(resul,partj) ;
	if( type(n) != "t_INT" || type(m) != "t_INT" || type(nmin) != "t_INT",
		error("One argument ", n, " or ", m, " or ", nmin, " to partitm() is not an integer!")
	) ;
	if( n < 0 || m <0 ,
		return([;]) ;
	) ;
	resul=matrix(0,m);
	if(m==0,
		return(resul);
	) ;
	/* The strategy is recursion. We split off any number j starting with
	* the minimum allowed and increasing it within the natural limits
	* set by n. Then we look which partitions could result supposed this
	* term had been removed from the sum and supposed the number of terms
	* were reduced by 1.
	*/
	for(j=max(1,nmin),n\m,
		partj=partitm(n-j,m-1,j) ;
		/* Essentially attach the number j to the front of each of the
		* subpartitions of n-j, and append that to the matrix of the
		* results.
		*/
		for(r1=1,matsize(partj)[1],
			resul=concat(resul,concat([j],partj[r1,])) ;
		) ;
	) ;
	if(m==1 && n >= nmin,
		resul=concat(resul,[[n]]) ;
	) ;
	return(resul) ;
}